﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PenoyShop.Utilities;
using System.Data.Common;
using System.Data;

namespace PeonyShop.DAL
{
    public class DACustomer : BaseDA
    {
        public DACustomer()
        { 

        }

        public bool LoginAdmin(string sUser, string sPassword, int RoleId)
        {
            bool bResult = false;
            try {
                DbCommand cmd = DB.GetStoredProcCommand("sp_AdminLogin");// aGetUserInfo  aGetAccInfoByUserID
                DB.AddInParameter(cmd, "@Username", SqlDbType.VarChar, sUser); //iwUserId 
                DB.AddInParameter(cmd, "@Password", SqlDbType.NChar, sPassword); //iwUserId 
                DB.AddInParameter(cmd, "@RoleId", SqlDbType.SmallInt, RoleId); //iwUserId 

                DataSet ds = DB.ExecuteDataSet(cmd);
                if (ds.Tables[0].Rows.Count == 0)
                    bResult = false;
                else
                    bResult = true;

            }
            catch (Exception ex)
            {
                Logger.FrameworkLogger.Error("Login ",ex);
                bResult = false;
            }

            return bResult;
        }
    }
}
